<?php
if( empty( $_SESSION ))
{
	session_start();
}
header("Content-Type: text/html; charset=utf-8",true);
include_once("../models/cls.pagina.php");

$oPagina = new pagina();
$oPagina->load( $_POST );

if( empty( $_POST["id"] ) )
{
	$add = $oPagina->insert();
	if($add == 1)
	{
		?>
		<script>
			alert("REGISTRO ADICIONADO!");
			window.location.href="../views/frm.edicao.controle.php<?php echo "?id=". $_SESSION["id_edicao"] ."&nome=". $_SESSION["nome_edicao"];?>";
		</script>
		<?php
	}
}
else{
	$add = $oPagina->update( $_POST["id"] );
	if($add == 1)
	{
		?>
		<script>
			alert("REGISTRO ALTERADO!");
			window.location.href="../views/frm.edicao.controle.php<?php echo "?id=". $_SESSION["id_edicao"] ."&nome=". $_SESSION["nome_edicao"];?>";
		</script>
		<?php
	}
}
?>